import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../../resource/ImagesConst";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { PetIlluEventName } from "./PetIlluEventName";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
type int = number;
//class PetIlluMenuRenderer
    
    export  class PetIlluMenuRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            addEventListener(flash.events.MouseEvent.ROLL_OVER, this.onMouseOver);
            addEventListener(flash.events.MouseEvent.ROLL_OUT, this.onMouseOut);
            addEventListener(flash.events.MouseEvent.CLICK, this.onClickHandler);
            this.buttonMode = true;
            return;
        }

        /* internal  */init(): void
        {
            this.graphics.beginFill(0, 0);
            this.graphics.drawRect(0, 0, 150, 25);
            this.graphics.endFill();
            this._nameTxt = ObjCreate.createTextField("", 42, 3, 220, 20, this);
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._nameTxt.multiline = true;
            this._nameTxt.mouseEnabled = false;
            this._overSkin = ResouceConst.getScaleBitmap(ImagesConst.SelectedBg);
            this._overSkin.width = 150;
            this._overSkin.height = 25;
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._itemObj = arg1;
            if (this._itemObj) 
            {
                this._name = this._itemObj.name;
                this._type = this._itemObj.type;
                this._category = this._itemObj.category;
                this._nameTxt.text = this._name;
            }
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            if (super.selected == arg1) 
            {
                return;
            }
            super.selected = arg1;
            if (arg1) 
            {
                addChildAt(this._overSkin, 0);
                this._nameTxt.textColor = 16121600;
                if (this._category != 0) 
                {
                    if (this._category == 1) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(PetIlluEventName.SearchSkillByType, this._type));
                    }
                }
                else 
                {
                    Dispatcher.dispatchEvent(new DataEvent(PetIlluEventName.SearchPetByType, this._type));
                }
                Dispatcher.dispatchEvent(new DataEvent(PetIlluEventName.SelectedMenuItem, this._category));
            }
            else 
            {
                if (this._overSkin.parent) 
                {
                    removeChild(this._overSkin);
                }
                this._nameTxt.textColor = 11661311;
            }
            return;
        }

        /* internal  */onMouseOver(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._itemObj && !this.selected) 
            {
                addChildAt(this._overSkin, 0);
            }
            return;
        }

        /* internal  */onClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            return;
        }

        /* internal  */onMouseOut(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!_selected) 
            {
                if (this._overSkin.parent) 
                {
                    removeChild(this._overSkin);
                }
            }
            return;
        }

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_overSkin: ScaleBitmap;

        /* internal */ /* var */_itemObj: Object;

        /* internal */ /* var */_name: string;

        /* internal */ /* var */_type: int;

        /* internal */ /* var */_category: int;
    }
